.root {
  --badge-height-xs: 16px;
  --badge-height-sm: 18px;
  --badge-height-md: 20px;
  --badge-height-lg: 26px;
  --badge-height-xl: 32px;

  --badge-fz-xs: 9px;
  --badge-fz-sm: 10px;
  --badge-fz-md: 11px;
  --badge-fz-lg: 13px;
  --badge-fz-xl: 16px;

  --badge-padding-x-xs: 6px;
  --badge-padding-x-sm: 8px;
  --badge-padding-x-md: 10px;
  --badge-padding-x-lg: 12px;
  --badge-padding-x-xl: 16px;

  --badge-height: var(--badge-height-md);
  --badge-fz: var(--badge-fz-md);
  --badge-padding-x: var(--badge-padding-x-md);
  --badge-radius: 1000px;
  --badge-lh: calc(var(--badge-height) - rem(2px));
  --badge-color: var(--mantine-color-white);
  --badge-bg: var(--mantine-primary-color-filled);
  --badge-border-width: 1px;
  --badge-bd: var(--badge-border-width) solid transparent;

  -webkit-tap-highlight-color: transparent;
  font-size: var(--badge-fz);
  border-radius: var(--badge-radius);
  height: var(--badge-height);
  line-height: var(--badge-lh);
  text-decoration: none;
  padding: 0 var(--badge-padding-x);
  display: inline-grid;
  align-items: center;
  justify-content: center;
  width: fit-content;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.25px;
  cursor: default;
  text-overflow: ellipsis;
  overflow: hidden;
  color: var(--badge-color);
  background: var(--badge-bg);
  border: var(--badge-bd);

  &:where([data-with-left-section], [data-variant='dot']) {
    grid-template-columns: auto 1fr;
  }

  &:where([data-with-right-section]) {
    grid-template-columns: 1fr auto;
  }

  &:where(
    [data-with-left-section][data-with-right-section],
    [data-variant='dot'][data-with-right-section]
  ) {
    grid-template-columns: auto 1fr auto;
  }

  &:where([data-block]) {
    display: flex;
    width: 100%;
  }

  &:where([data-circle]) {
    padding-inline: 2px;
    display: flex;
    width: var(--badge-height);
  }
}

.root--dot {
  --badge-dot-size: calc(var(--badge-height) / 3.4);

  @mixin where-light {
    background-color: var(--mantine-color-white);
    border-color: var(--mantine-color-gray-4);
    color: var(--mantine-color-black);
  }

  @mixin where-dark {
    background-color: var(--mantine-color-dark-5);
    border-color: var(--mantine-color-dark-5);
    color: var(--mantine-color-white);
  }

  &::before {
    content: '';
    display: block;
    width: var(--badge-dot-size);
    height: var(--badge-dot-size);
    border-radius: var(--badge-dot-size);
    background-color: var(--badge-dot-color);
    margin-inline-end: var(--badge-dot-size);
  }
}

.label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  cursor: inherit;
}

.section {
  --badge-section-margin: calc(var(--mantine-spacing-xs) / 2);

  display: inline-flex;
  justify-content: center;
  align-items: center;
  max-height: calc(var(--badge-height) - var(--badge-border-width) * 2);

  &:where([data-position='left']) {
    margin-inline-end: var(--badge-section-margin);
  }

  &:where([data-position='right']) {
    margin-inline-start: var(--badge-section-margin);
  }
}
